package com.openbravo.pos.util;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import org.krysalis.barcode4j.BarcodeDimension;
import org.krysalis.barcode4j.HumanReadablePlacement;
import org.krysalis.barcode4j.impl.AbstractBarcodeBean;
import org.krysalis.barcode4j.impl.codabar.CodabarBean;
import org.krysalis.barcode4j.impl.code128.Code128Bean;
import org.krysalis.barcode4j.impl.code39.Code39Bean;
import org.krysalis.barcode4j.impl.int2of5.Interleaved2Of5Bean;
import org.krysalis.barcode4j.impl.postnet.POSTNETBean;
import org.krysalis.barcode4j.impl.upcean.EAN13Bean;
import org.krysalis.barcode4j.impl.upcean.EAN8Bean;
import org.krysalis.barcode4j.impl.upcean.UPCABean;
import org.krysalis.barcode4j.impl.upcean.UPCEBean;
import org.krysalis.barcode4j.output.java2d.Java2DCanvasProvider;

public class BarcodeImage
{
  public static Image getBarcodeCodabar(String paramString)
  {
    CodabarBean localCodabarBean = new CodabarBean();
    localCodabarBean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM);
    return getBarcode(paramString, localCodabarBean);
  }

  public static Image getBarcodeCode39(String paramString)
  {
    Code39Bean localCode39Bean = new Code39Bean();
    localCode39Bean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM);
    return getBarcode(paramString, localCode39Bean);
  }

  public static Image getBarcodeInterleaved2Of5(String paramString)
  {
    Interleaved2Of5Bean localInterleaved2Of5Bean = new Interleaved2Of5Bean();
    localInterleaved2Of5Bean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM);
    return getBarcode(paramString, localInterleaved2Of5Bean);
  }

  public static Image getBarcodePOSTNET(String paramString)
  {
    POSTNETBean localPOSTNETBean = new POSTNETBean();
    localPOSTNETBean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM);
    return getBarcode(paramString, localPOSTNETBean);
  }

  public static Image getBarcodeUPCA(String paramString)
  {
    UPCABean localUPCABean = new UPCABean();
    localUPCABean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM);
    return getBarcode(paramString, localUPCABean);
  }

  public static Image getBarcodeUPCE(String paramString)
  {
    UPCEBean localUPCEBean = new UPCEBean();
    localUPCEBean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM);
    return getBarcode(paramString, localUPCEBean);
  }

  public static Image getBarcodeEAN13(String paramString)
  {
    EAN13Bean localEAN13Bean = new EAN13Bean();
    localEAN13Bean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM);
    return getBarcode(paramString, localEAN13Bean);
  }

  public static Image getBarcodeEAN8(String paramString)
  {
    EAN8Bean localEAN8Bean = new EAN8Bean();
    localEAN8Bean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM);
    return getBarcode(paramString, localEAN8Bean);
  }

  public static Image getBarcode128(String paramString)
  {
    Code128Bean localCode128Bean = new Code128Bean();
    localCode128Bean.setMsgPosition(HumanReadablePlacement.HRP_NONE);
    return getBarcode(paramString, localCode128Bean);
  }

  private static Image getBarcode(String paramString, AbstractBarcodeBean paramAbstractBarcodeBean)
  {
    paramAbstractBarcodeBean.setModuleWidth(1.0D);
    paramAbstractBarcodeBean.setBarHeight(40.0D);
    paramAbstractBarcodeBean.setFontSize(10.0D);
    paramAbstractBarcodeBean.setQuietZone(10.0D);
    paramAbstractBarcodeBean.doQuietZone(true);
    BarcodeDimension localBarcodeDimension = paramAbstractBarcodeBean.calcDimensions(paramString);
    int i = (int)localBarcodeDimension.getWidth(0) + 20;
    int j = (int)localBarcodeDimension.getHeight(0);
    BufferedImage localBufferedImage = new BufferedImage(i, j, 1);
    Graphics2D localGraphics2D = localBufferedImage.createGraphics();
    localGraphics2D.setColor(Color.WHITE);
    localGraphics2D.fillRect(0, 0, i, j);
    localGraphics2D.setColor(Color.BLACK);
    try
    {
      paramAbstractBarcodeBean.generateBarcode(new Java2DCanvasProvider(localGraphics2D, 0), paramString);
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      localGraphics2D.drawRect(0, 0, i - 1, j - 1);
      localGraphics2D.drawString(paramString, 2, j - 3);
    }
    localGraphics2D.dispose();
    return localBufferedImage;
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.util.BarcodeImage
 * JD-Core Version:    0.6.0
 */